package com.jss.lanouhn.fristapp.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jss.lanouhn.fristapp.R;
import com.jss.lanouhn.fristapp.utils.AnimUtil;
import com.ybao.pullrefreshview.layout.BaseFooterView;
import com.ybao.pullrefreshview.support.type.LayoutType;

/**
 * Created by Ybao on 2015/11/3 0003.
 */
public class NormalFooterView extends BaseFooterView {

    TextView textView;
    ImageView imageView;

    public NormalFooterView(Context context) {
        this(context, null);
    }

    public NormalFooterView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public NormalFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_footer_normal, this, true);
        textView = (TextView) findViewById(R.id.text);
        imageView= (ImageView) findViewById(R.id.iv_footer_view);

    }


    @Override
    protected void onStateChange(int state) {

        textView.setVisibility(View.VISIBLE);
        imageView.setVisibility(VISIBLE);
        switch (state) {
            case NONE:
                break;
            case PULLING:
                textView.setText("上拉加载更多");

                break;
            case LOOSENT_O_LOAD:
                textView.setText("松开加载");
                break;
            case LOADING:
                textView.setText("正在加载");
                AnimUtil.startRotation(imageView,360f,1500,100);

                break;
            case LOAD_CLONE:


                textView.setVisibility(View.INVISIBLE);
                imageView.setVisibility(View.INVISIBLE);
                textView.setText("加载完成");
                break;

        }

    }

    @Override
    public float getSpanHeight() {

        return getHeight();
    }

    @Override
    public int getLayoutType() {
        return LayoutType.LAYOUT_NORMAL;
    }
}
